#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

// 594. 最长和谐子序列
// https://leetcode.cn/problems/longest-harmonious-subsequence/description/?envType=daily-question&envId=2025-06-30

class Solution
{
public:
    int findLHS(vector<int> &nums)
    {
        unordered_map<int, int> freq;
        for (int i = 0; i < nums.size(); i++)
        {
            freq[nums[i]]++;
        }
        int ans = 0;
        for (auto &it : freq)
        {
            int sum = 0;
            if (freq.find(it.first + 1) != freq.end())
            {
                sum = freq[it.first] + freq[it.first + 1];
            }
            ans = max(ans, sum);
        }
        return ans;
    }
};

int main()
{
    return 0;
}